/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function replaceChars(entry) {
	out = "."; // replace this
	add = ""; // with this
	temp = "" + entry; // temporary holder

	while (temp.indexOf(out)>-1) {
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add + 
	temp.substring((pos + out.length), temp.length));
	}
}

function trimNumber(s) {
	while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
	while (s.substr(0,1) == '.' && s.length>1) { s = s.substr(1,9999); }
	return s;
}

function format_uang(objek) {
	a = objek.value;
	b = a.replace(/[^\d]/g,"");
	c = "";
	panjang = b.length;
	j = 0;
	for (i = panjang; i > 0; i--) {
	j = j + 1;
	if (((j % 3) == 1) && (j != 1)) {
	c = b.substr(i-1,1) + "." + c;
	} else {
	c = b.substr(i-1,1) + c;
	}
	}
	objek.value = trimNumber(c);
}

